<?php
namespace control;
/*
*材料需求计划类
*/

class materialDemandClass extends adIndexClass
{
    private const page = 'materialDemand';
    private const title = '材料需求计划';

    /**
     * 字段初始化
     */
    public function fieldInit($fun): array
    {
        switch ($fun) {
            case 'summarySearch':
                $tr = [
                    'recordDate'          => [
                        'name'  => "单据日期",
                        'width' => 200,
                        'sort' => 1,
                    ],
                    'code'  => [
                        'name'  => '物料编码',
                        'width' => 250,
                        'sort' => 1,
                    ],
                    'materialName'         => [
                        'name'  => '物料名称',
                        'width' => 250,
                    ],
                    'model'          => [
                        'name'  => '规格型号',
                        'width' => 250,
                    ],
                    'unit'          => [
                        'name'  => '单位',
                        'width' => 200,
                    ],
                    'quantity'          => [
                        'name'  => '需求数量',
                        'width' => 200,
                        'sort' => 1,
                    ],
                    'stockNum'          => [
                        'name'  => '库存数量',
                        'width' => 200,
                    ]
                ];
                break;
            case 'materialSummarySearch':
                $tr = [
                    'code'  => [
                        'name'  => '物料编码',
                        'width' => 250,
                        'sort' => 1,
                    ],
                    'materialName'         => [
                        'name'  => '物料名称',
                        'width' => 250,
                    ],
                    'model'          => [
                        'name'  => '规格型号',
                        'width' => 200,
                    ],
                    'unit'          => [
                        'name'  => '单位',
                        'width' => 200,
                    ],
                    'quantity'          => [
                        'name'  => '需求数量',
                        'width' => 200,
                        'sort' => 1,
                    ],
                    'stockNum'          => [
                        'name'  => '库存数量',
                        'width' => 200,
                    ],
                    'residue'          => [
                        'name'  => '待采购数量',
                        'width' => 200,
                    ]
                ];
                break;
            default:
                $tr = [
                    'recordDate'          => [
                        'name'  => "单据日期",
                        'width' => 120,
                        'sort' => 1,
                    ],
                    'orderNo' => [
                        'name'  => "生产计划单号",
                        'width' => 200,
                        'sort' => 1,
                    ],
                    'code'  => [
                        'name'  => '物料编码',
                        'width' => 200,
                        'sort' => 1,
                    ],
                    'materialName'         => [
                        'name'  => '物料名称',
                        'width' => 150,
                    ],
                    'model'          => [
                        'name'  => '规格型号',
                        'width' => 150,
                    ],
                    'unit'          => [
                        'name'  => '单位',
                        'width' => 60,
                    ],
                    'text'          => [
                        'name'  => '备注',
                        'width' => 200,
                    ],
                    'num'          => [
                        'name'  => '需求数量',
                        'width' => 120,
                        'sort' => 1,
                    ],
                    'stockNum'          => [
                        'name'  => '库存数量',
                        'width' => 120,
                    ],
                    'needTime'          => [
                        'name'  => '需料时间',
                        'width' => 150,
                        'sort' => 1,
                    ]
                ];
        }
        return $tr;
    }

    /*列表页-查询条件*/
    public function homeOptions($isAsync = true)
    {
        //生成查询表单
        $html = $this->tableShow([
            [
                [
                    "生产计划单号" => text(array("name" => "orderNo")),
                    "物料编码"   => text(array("name" => "code")),
                    "物料名称"   => text(array("name" => "materialName")),
                ],
                [
                    "单据日期" => text(array("name" => "createTime", 'laydate' => ['type' => 'date', 'range' => '~'])),
                ]
            ]
        ],1);
        //返回
        if (!$isAsync) {
            return $html;
        } else {
            return json_encode(['html' => $html], 320);
        }
    }

    /*列表-查询条件*/
    public function home()
    {
        $html = $this->homeOptions(false);
        //控件
        $button = "<span class='spanButton' onclick=\"layer('" . self::page . "','purchaseApply','listForm')\">生成采购申请</span>";
        $button .= "<span class='spanButton' onclick=\"layer('" . self::page . "','createPurchaseOrder','listForm')\">生成采购单</span>";
        //$button .= "<span class='spanButton' onclick=\"layer('" . self::page . "','allot','listForm')\">生成调拨单</span>";

        if ($this->power(self::page, "export")) {
            $button .="<span class='spanButton' onclick=\"layer('importTemplate','exportFrame',{cla:'".self::page."',source:'detail',classify:'材料需求计划明细'})\">导出</span>";
        }
        return $this->homeFun($this->search($html, layout: 'pop', toolButton: $button));
    }

    /*查询结果*/
    public function homeSearch()
    {
        //like查询数组
        $like = array(
            "b.orderNo" => $this->post('orderNo'),//证件编号
            "c.name" => $this->post('materialName'),
            "c.code" => $this->post('code'),
        );
        //全等查询数组
        $equal = array(
            "a.coid" => self::$coid,
            "b.state" => '已确认'
        );
        $and = '';
        if ($this->post('createTime')) {
            //单据日期
            $and .= self::timeComparison($this->post('createTime'),field: 'b.recordDate');
        }
        //排序
        $orderBy = $this->listSort(array(
            "search"  => $this->post('list_sort_key') ?: 'b.recordDate desc,a.list',
            "sort" => $this->post('list_sort') ?: "asc",
            "array"   => array(),
        ));
        //获取查询结果
        $where = search(array("like" => $like, "=" => $equal)) . $and;
        $page = $this->page(array(
            "table" => "machining_demands as a join machining_order as b on a.sourceId = b.id join material as c on c.id = a.materialId",
            'field' => "a.*,b.orderNo,b.recordDate,b.text,c.code,c.name as materialName,c.model",
            "where" => $where,
            "order" => $orderBy['orderBy']
        ));
        static::rSet(self::$stid.self::page.'Sql',$page['fullSql']);
        //获取自定义字段参数
        $installSearch = $this->installSearch();
        $body          = [];
        //表格控件区
        $liButton = array(
            $this->checkAll("listForm", "listId")
        );
        //获取记录
        foreach ($page['array'] as $array) {
            //列表控件
            $dominate = array(
                "box" => array("name" => "listId", "value" => $array['id']),
            );
            $liButton[] = $this->dominate($dominate);
            //本行初始化
            $row = [];
            foreach ($installSearch['key'] as $key) {
                switch ($key) {
                    case 'num':
                        $row[] = self::lostZero($array['num'],'numPrecision');
                        break;
                    case 'stockNum':
                        $stockNum = inventoryBalanceClass::inventoryNum($array['materialId'], unit:$array['unit']);//库存数量
                        $row[] = $stockNum;
                        break;
                    default:
                        $row[] = isset($array[$key]) && $array[$key] ? $array[$key] : '';
                }
            }
            $body[] = $row;
        }
        $totalQuery = find([
            'table'  => "machining_demands as a join machining_order as b on a.sourceId = b.id join material as c on c.id = a.materialId",
            'single' => $where,
            'field'  => "ifnull(sum(a.num),0) as num",
        ]);
        $total    = [
            'num'        => self::lostZero($totalQuery['num'], 'numPrecision'),
        ];
        //生成页面
        $li = $this->li(array(
            "body" => $body,
            "install" => $installSearch,
            "button" => array("html" => $liButton),
            "orderBySign" => $orderBy,
            "page" => $page['para'],
            "total"       => $total,
        ));
        //返回
        $json['html'] = $page['hint'] . "<form name='listForm'>" . $li . "</form>" . $this->js() . $page['button'] . clear;
        return json_encode($json, 320);
    }

    /*列表页-查询条件*/
    public function summaryOptions($isAsync = true)
    {
        //生成查询表单
        $html = $this->tableShow([
            [
                [
                    "物料编码"   => text(array("name" => "code")),
                    "物料名称"   => text(array("name" => "materialName")),
                    "单据日期" => text(array("name" => "createTime", 'laydate' => ['type' => 'date', 'range' => '~'])),
                ]
            ]
        ],1);
        //返回
        if (!$isAsync) {
            return $html;
        } else {
            return json_encode(['html' => $html], 320);
        }
    }

    /**
     * 汇总
     * @return bool|string
     */
    public function summary(): bool|string
    {
        $html = $this->summaryOptions(false);
        //控件
        $button='';
        if ($this->power('materialDemandDate', "export")) {
            $button .="<span class='spanButton' onclick=\"layer('importTemplate','exportFrame',{cla:'".self::page."',source:'all',classify:'按日期汇总材料需求'})\">导出</span>";
        }
        return $this->homeFun($this->search($html, layout: 'pop', toolButton: $button));
    }

    /**
     * 汇总
     * @return bool|string
     */
    public function summarySearch(): bool|string
    {
        //like查询数组
        $like = array(
            "c.name" => $this->post('materialName'),
            "c.code" => $this->post('code'),
        );
        //全等查询数组
        $equal = array(
            "a.coid" => self::$coid,
            "b.state" => '已确认'
        );
        $and = ' and 1=1';
        if ($this->post('createTime')) {
            //单据日期
            $and .= self::timeComparison($this->post('createTime'),field: 'recordDate');
        }
        //排序
        $orderBy = $this->listSort(array(
            "search"  => $this->post('list_sort_key') ?: 'b.recordDate',
            "sort" => $this->post('list_sort') ?: "desc",
            "array"   => array(),
        ));
        //获取查询结果
        $where = $whereTotal = search(array("like" => $like, "=" => $equal)) . $and;
        $where .= " group by a.materialId,b.recordDate,a.unit";
        $page = $this->page(array(
            "table" => "machining_demands as a join machining_order as b on a.sourceId = b.id join material as c on c.id = a.materialId",
            'field' => "a.materialId,any_value(c.code) as code,any_value(c.model) as model,any_value(c.name) as materialName,b.recordDate,a.unit,ifnull(sum(a.num),0) as quantity",
            "where" => $where,
            "order" => $orderBy['orderBy']
        ));
        static::rSet(self::$stid.self::page.'SqlAll',$page['fullSql']);
        //获取自定义字段参数
        $installSearch = $this->installSearch();
        $body          = [];
        //表格控件区
        $liButton = array();
        //获取记录
        foreach ($page['array'] as $array) {
            //本行初始化
            $row = [];
            foreach ($installSearch['key'] as $key) {
                switch ($key) {
                    case 'quantity':
                        $row[] = self::lostZero($array['quantity'],'numPrecision');
                        break;
                    case 'stockNum':
                        $stockNum = inventoryBalanceClass::inventoryNum($array['materialId'], unit:$array['unit']);//库存数量
                        $row[] = $stockNum;
                        break;
                    default:
                        $row[] = isset($array[$key]) && $array[$key] ? $array[$key] : '';
                }
            }
            $body[] = $row;
        }
        //控件
        $needTotal = find(array(
            "table" => "machining_demands as a join machining_order as b on a.sourceId = b.id join material as c on c.id = a.materialId",
            "field" => " ifnull(sum(a.num),0) as quantity ",
            "single" => $whereTotal
        ))['quantity'];
        $total = [
            'quantity' => self::lostZero($needTotal,'numPrecision'),
        ];
        //生成页面
        $li = $this->li(array(
            "body" => $body,
            "install" => $installSearch,
            "button" => array("html" => $liButton),
            "orderBySign" => $orderBy,
            "page" => $page['para'],
            "total" => $total,
        ));
        //返回
        $json['html'] = $page['hint'] . "<form name='listForm'>" . $li . "</form>" . $this->js() . $page['button'] . clear;
        return json_encode($json, 320);
    }

    /*列表页-查询条件*/
    public function materialSummaryOptions($isAsync = true)
    {
        //生成查询表单
        $html = $this->tableShow([
            [
                [
                    "物料编码"   => text(array("name" => "code")),
                    "物料名称"   => text(array("name" => "materialName")),
                ]
            ]
        ],1);
        //返回
        if (!$isAsync) {
            return $html;
        } else {
            return json_encode(['html' => $html], 320);
        }
    }

    public function materialSummary(){
        $html = $this->materialSummaryOptions(false);
        //控件
        $button='';
        if ($this->power('materialDemandSummary', "export")) {
            $button .="<span class='spanButton' onclick=\"layer('importTemplate','exportFrame',{cla:'".self::page."',source:'materialAll',classify:'按物料汇总材料需求'})\">导出</span>";
        }
        return $this->homeFun($this->search($html, layout: 'pop', toolButton: $button));
    }
    /**
     * 汇总
     * @return bool|string
     */
    public function materialSummarySearch(): bool|string
    {
        //like查询数组
        $like = array(
            "c.name" => $this->post('materialName'),
            "c.code" => $this->post('code'),
        );
        //全等查询数组
        $equal = array(
            "a.coid" => self::$coid,
        );
        $and = ' and 1=1';
        if ($this->post('createTime')) {
            //单据日期
            $and .= self::timeComparison($this->post('createTime'),field: 'recordDate');
        }
        //排序
        $orderBy = $this->listSort(array(
            "search"  => $this->post('list_sort_key') ?: 'code',
            "sort" => $this->post('list_sort') ?: "asc",
            "array"   => array(),
        ));
        //获取查询结果
        $where = $whereTotal = search(array("like" => $like, "=" => $equal)) . $and;
        $where .= " group by a.materialId,a.unit";
        $page = $this->page(array(
            "table" => "machining_demands as a join material as c on c.id = a.materialId",
            'field' => "a.materialId,any_value(c.code) as code,any_value(c.model) as model,any_value(c.name) as materialName,a.unit,ifnull(sum(a.num),0) as quantity",
            "where" => $where,
            "order" => $orderBy['orderBy']
        ));
        static::rSet(self::$stid.self::page.'SqlMaterialAll',$page['fullSql']);
        //获取自定义字段参数
        $installSearch = $this->installSearch();
        $body          = [];
        //表格控件区
        $liButton = array();
        //获取记录
        foreach ($page['array'] as $array) {
            $material = query('material',"id = '$array[materialId]'");
            $stockNum =inventoryBalanceClass::inventoryNum($array['materialId'], unit:$array['unit']);//库存数量
            $stockNum = machiningOrderClass::material_num_change($array['materialId'],$material['unit'],$array['unit'],$stockNum);
            //本行初始化
            $row = [];
            foreach ($installSearch['key'] as $key) {
                switch ($key) {
                    case 'quantity':
                        $row[] = self::lostZero($array['quantity'],'numPrecision');
                        break;
                    case 'stockNum':
                        $row[] = $stockNum;
                        break;
                    case 'residue':
                        $row[] = self::lostZero($array['quantity']-$stockNum >0?($array['quantity']-$stockNum):0,'numPrecision');
                        break;
                    default:
                        $row[] = isset($array[$key]) && $array[$key] ? $array[$key] : '';
                }
            }
            $body[] = $row;
        }
        //控件
        $needTotal = find(array(
            "table" => "machining_demands as a join material as c on c.id = a.materialId",
            "field" => " ifnull(sum(a.num),0) as quantity ",
            "single" => $whereTotal
        ))['quantity'];
        $total = [
            'quantity' => self::lostZero($needTotal,'numPrecision'),
        ];
        //生成页面
        $li = $this->li(array(
            "body" => $body,
            "install" => $installSearch,
            "button" => array("html" => $liButton),
            "orderBySign" => $orderBy,
            "page" => $page['para'],
            "total"       => $total,
        ));
        //返回
        $json['html'] = $page['hint'] . "<form name='listForm'>" . $li . "</form>" . $this->js() . $page['button'] . clear;
        return json_encode($json, 320);
    }
    public function purchaseApply(): bool|string
    {
        //生成表单
        $html = $this->layerEdit(array("table" => array(
            array(
                "提示：" => "是否确认生成采购申请？",
            ),
        )));
        //返回
        return $this->layer(array(
            "title" => "生成采购申请",
            "height" => 165,
            "html" => $html,
            'button' => "<input onclick=\"commitOrder('purchaseApply')\" type='button' class='button' value='确认'>",
            'formTwo' => 'listForm'
        ));
    }


    public function createPurchaseOrder(): bool|string
    {
        //生成表单
        $html = $this->layerEdit(array("table" => array(
            array(
                "提示：" => "是否确认生成采购订单？",
            ),
        )));
        //返回
        return $this->layer(array(
            "title" => "生成采购订单",
            "height" => 165,
            "html" => $html,
            'button' => "<input onclick=\"commitOrder('purchaseOrder')\" type='button' class='button' value='确认'>",
            'formTwo' => 'listForm'
        ));
    }

    public function allot(){
        //生成表单
        $html = $this->layerEdit(array("table" => array(
            array(
                "调出仓库：" => selectMultiple(['table' => 'warehouse', "title" => '请选择', 'where' => " coid = '" . self::$coid . "' AND state = '启用' ", 'sqlField' => 'name', 'sqlId' => 'id', 'name' => 'warehouseId']),
            ),
        )));
        //返回
        return $this->layer(array(
            "title" => "生成调拨单",
            'winFix'=>true,
            "height" => 165,
            "html" => $html,
            'button' => "<input onclick=\"allotOrder()\" type='button' class='button' value='确认'>",
            'formTwo' => 'listForm'
        ));
    }


    public function js(): string
    {
        return <<<eof
<script>

//提交采购单
function commitOrder(type){
    if (type =='purchaseOrder'){
         $('#materialDemandCreatePurchaseOrder').hide()
        let arr = [];
        $("[name='listForm'] input[type=checkbox]:checked").each(function () {
            if ($(this).val() && $(this).val() !== 'on') {
                arr.push($(this).val());
            }
        });
        if (arr.length ===0){
            msg('请选择数据','error')
            return false;
        }
        let listId = arr.join(",");
        newIframe('采购订单',root+'control/adIndex.html?cla=purchaseOrder&fun=edit&source=materialDemand&listId='+listId,'供应链','采购')
    }else if(type =='purchaseApply'){
       $('#materialDemandPurchaseApply').hide()
        let arr = [];
        $("[name='listForm'] input[type=checkbox]:checked").each(function () {
            if ($(this).val() && $(this).val() !== 'on') {
                arr.push($(this).val());
            }
        });
        if (arr.length ===0){
            msg('请选择数据','error')
            return false;
        }
        let listId = arr.join(",");
        newIframe('采购申请',root+'control/adIndex.html?cla=purchaseApply&fun=edit&source=materialDemand&listId='+listId,'供应链','采购')
    }
   
    
}
//生成调拨单
function allotOrder(){
    $('#materialDemandAllot').hide()
    let arr = [];
    $("[name='listForm'] input[type=checkbox]:checked").each(function () {
        if ($(this).val() && $(this).val() !== 'on') {
            arr.push($(this).val());
        }
    });
    if (arr.length ===0){
        msg('请选择数据','error')
        return false;
    }
    let listId = arr.join(",");
    let warehouseId = $("[name='warehouseId']").val();
    newIframe('调拨单',root+'control/adIndex.html?cla=inventoryAllot&fun=edit&source=materialDemand&listId='+listId+'&warehouseId='+warehouseId,'供应链','库存')
}
</script>
eof;

    }

    /**
     * 导出
     */
    public function exportData()
    {
        $templateId = $this->get('templateId');
        $checkedId = $this->get('checkedId')?explode(',',$this->get('checkedId')):[];
        $source = $this->get('source');
        if($source =='all'){
            $power = 'materialDemandDate';
        }elseif($source == 'materialAll'){
            $power = 'materialDemandSummary';
        }else{
            $power = 'materialDemand';
        }
        if (!$this->power($power, 'export')) {
            $_SESSION['warn'] = '你还没有导出的权限';
        } elseif(empty($source)){
            $_SESSION['warn'] = '未找到类型';
        }else {
            $data = [];
            /***********标题**********/
            $title =[];
            $tempFieldAll = importTemplateClass::templateField(self::page, 'exportFieldInit', id:$templateId);
            foreach ($tempFieldAll as $array) {
                if ($array['display']){
                    $title[] = $array['aliasName'];
                }
            }
            if($source =='materialAll'){
                $sql = static::rGet(self::$stid.self::page.'SqlAll');

                $result = sqlFind($sql);
                //导出数据生成
                foreach ($result as $array){
                    $column = [];
                    $stockNum = machiningOrderClass::inventory($array['materialId'],$array['unit']);//库存数量
                    foreach ($tempFieldAll as $templateField){
                        if ($templateField['display']){
                            $column[] = match ($templateField['columnName']){
                                '物料编码'=>$array['code'],
                                '物料名称'=>$array['materialName'],
                                '规格型号'=>$array['model'],
                                '单位'=>$array['unit'],
                                '需求数量'=>self::lostZero($array['quantity'],'numPrecision'),
                                '库存数量'=>self::lostZero($stockNum,'numPrecision'),
                                '待采购数量'=>self::lostZero($array['quantity']-$stockNum >0?($array['quantity']-$stockNum):0,'numPrecision'),
                                default=>'',
                            };
                        }
                    }
                    $data[] = $column;
                }
                $excelTitle = '材料需求计划按物料汇总表';
            }elseif($source == 'all'){
                $sql = static::rGet(self::$stid.self::page.'SqlMaterialAll');
                $result = sqlFind($sql);
                //导出数据生成
                foreach ($result as $array){
                    $column = [];
                    $stockNum = inventoryBalanceClass::inventoryNum($array['materialId'], unit:$array['unit']);//库存数量
                    foreach ($tempFieldAll as $templateField){
                        if ($templateField['display']){
                            $column[] = match ($templateField['columnName']){
                                '单据日期'=>$array['recordDate'],
                                '物料编码'=>$array['code'],
                                '物料名称'=>$array['materialName'],
                                '规格型号'=>$array['model'],
                                '单位'=>$array['unit'],
                                '需求数量'=>self::lostZero($array['num'],'numPrecision'),
                                '库存数量'=>$stockNum,
                                default=>'',
                            };
                        }
                    }
                    $data[] = $column;
                }
                $excelTitle = '材料需求计划按日期汇总表';
            }else{
                //判断是否选中导出
                if (!self::is_null_array($checkedId)){
                    $result = find(array(
                        "table" => "machining_demands as a join machining_order as b on a.sourceId = b.id join material as c on c.id = a.materialId",
                        'field' => "a.*,b.orderNo,b.recordDate,b.text,c.code,c.name as materialName,c.model",
                        "where" => "a.id in ('".implode("','", $checkedId)."') order by b.recordDate desc,a.list asc",
                    ))['array'];
                }else{
                    $sql = static::rGet(self::$stid.self::page.'Sql');
                    $result   = sqlFind($sql);
                }
                //导出数据生成
                foreach ($result as $array){
                    $column = [];
                    $stockNum = inventoryBalanceClass::inventoryNum($array['materialId'], unit:$array['unit']);//库存数量
                    foreach ($tempFieldAll as $templateField){
                        if ($templateField['display']){
                            $column[] = match ($templateField['columnName']){
                                '单据日期'=>$array['recordDate'],
                                '生产计划单号'=>$array['orderNo'],
                                '物料编码'=>$array['code'],
                                '物料名称'=>$array['materialName'],
                                '规格型号'=>$array['model'],
                                '单位'=>$array['unit'],
                                '备注'=>$array['text'],
                                '需求数量'=>self::lostZero($array['num'],'numPrecision'),
                                '库存数量'=>$stockNum,
                                '需料时间'=>$array['needTime'],
                                default=>'',
                            };
                        }
                    }
                    $data[] = $column;
                }
                $excelTitle = '材料需求计划明细表';
            }
            $text = $this->control['name'] . "导出了".$excelTitle;
            $this->logText(["type" => $power, "text" => $text]);
            $this->excelOut($title, $data, $excelTitle.".xlsx");
            exit(0);
        }
        header("Location:" . getenv("HTTP_REFERER"));
    }

    /**
     * 导出模板字段初始化
     * @return array[]
     */
    public function exportFieldInit($classify=''): array
    {
        return match ($classify) {
            '按日期汇总材料需求'=>[
                [
                    'columnName'=>'单据日期',
                    'aliasName'=>'单据日期',
                ],
                [
                    'columnName'=>'物料编码',
                    'aliasName'=>'物料编码',
                ],
                [
                    'columnName'=>'物料名称',
                    'aliasName'=>'物料名称',
                ],
                [
                    'columnName'=>'规格型号',
                    'aliasName'=>'规格型号',
                ],
                [
                    'columnName'=>'单位',
                    'aliasName'=>'单位',
                ],
                [
                    'columnName'=>'需求数量',
                    'aliasName'=>'需求数量',
                ],
                [
                    'columnName'=>'库存数量',
                    'aliasName'=>'库存数量',
                ],
            ],
            '按物料汇总材料需求'=>[
                [
                    'columnName'=>'物料编码',
                    'aliasName'=>'物料编码',
                ],
                [
                    'columnName'=>'物料名称',
                    'aliasName'=>'物料名称',
                ],
                [
                    'columnName'=>'规格型号',
                    'aliasName'=>'规格型号',
                ],
                [
                    'columnName'=>'单位',
                    'aliasName'=>'单位',
                ],
                [
                    'columnName'=>'需求数量',
                    'aliasName'=>'需求数量',
                ],
                [
                    'columnName'=>'库存数量',
                    'aliasName'=>'库存数量',
                ],
                [
                    'columnName'=>'待采购数量',
                    'aliasName'=>'待采购数量',
                ],
            ],
            default=>  [
                [
                    'columnName'=>'单据日期',
                    'aliasName'=>'单据日期',
                ],
                [
                    'columnName'=>'生产计划单号',
                    'aliasName'=>'生产计划单号',
                ],
                [
                    'columnName'=>'物料编码',
                    'aliasName'=>'物料编码',
                ],
                [
                    'columnName'=>'物料名称',
                    'aliasName'=>'物料名称',
                ],
                [
                    'columnName'=>'规格型号',
                    'aliasName'=>'规格型号',
                ],
                [
                    'columnName'=>'单位',
                    'aliasName'=>'单位',
                ],
                [
                    'columnName'=>'备注',
                    'aliasName'=>'备注',
                ],
                [
                    'columnName'=>'需求数量',
                    'aliasName'=>'需求数量',
                ],
                [
                    'columnName'=>'库存数量',
                    'aliasName'=>'库存数量',
                ],
                [
                    'columnName'=>'需料时间',
                    'aliasName'=>'需料时间',
                ],
            ]
        };
    }
}
